package com.zbf4.config;

import com.zbf4.intercepter.TestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/5/21  9:52
 * 描述:
 */
@Configuration
public class TestWebMvcConfigure implements WebMvcConfigurer {

    @Autowired
    private TestConfigEntity testConfigEntity;

    @Autowired
    private TestInterceptor testInterceptor;


    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(testInterceptor).addPathPatterns(testConfigEntity.getListpath());
    }


    @Bean("threadPoolExecutor")
    public ThreadPoolExecutor getThreadPoolExecutor(){
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(10,10,50,TimeUnit.SECONDS,new LinkedBlockingDeque<Runnable>());
        return threadPoolExecutor;
     }



}
